//
//  ABObject.h
//  afnetworkingtest
//
//  Created by appbegin on 14-2-8.
//  Copyright (c) 2014年 appbegin. All rights reserved.
//

#import <Foundation/Foundation.h>
@class SEObject;
//typedef void (^ABResultBlock)(BOOL succeeded, NSError *error);
typedef void (^ABFailureBlock)(NSError *error);
//登录失败！
//typedef void (^ABFailureWithMsgBlock)(NSString *errorMsg);
typedef void (^ABResultsSuccessBlock)(NSDictionary *dataDic);
typedef void (^ABResultsArraySuccessBlock)(NSArray *dataDic);
typedef void (^ABSaveSuccessBlock)(SEObject *object);
typedef void (^ABFindSuccessBlock)(SEObject *objects);
typedef void (^ABGetSuccessBlock)(SEObject *object);
//typedef void (^ABGetFileSuccessBlock)(NSURL *filePath);
//typedef void (^ABSignInSuccessBlock)(SEObject *object);
//typedef void (^ABSignUpSuccessBlock)(SEObject *object);
//typedef void (^ABPasswordResetSuccessBlock)();
//typedef void (^ABPasswordModifySuccessBlock)();
//typedef void (^ABVerificationSendSuccessBlock)();
//typedef void (^ABPhoneVerifySuccessBlock)();
//typedef void (^ABUploadFileSuccessBlock)();





typedef void (^ABExcuteResult)(NSDictionary *objects);

@interface SEObject : NSObject
{
    NSString *_objectId;
    NSString *_className;
    NSDate *_updatedAt;
    NSDate *_createdAt;
}

#pragma mark -
#pragma mark Properties

/*! @name Managing Object Properties */

/*!
 The id of the object.
 */
@property (nonatomic, retain) NSString *objectId;

/*!
 When the object was last updated.
 */
@property (readonly) NSDate *updatedAt;

/*!
 When the object was created.
 */
@property (readonly) NSDate *createdAt;

/*!
 The class name of the object.
 */
@property (strong, nonatomic) NSString *className;

@property (strong, nonatomic) NSMutableDictionary *saveDataDic;

+ (SEObject *)objectWithClassName:(NSString *)className;
- (id)initWithClassName:(NSString *)newClassName;
//add object
- (void)setObject:(id)value forKey:(NSString *)aKey;
//query object
- (id)objectForKey:(NSString *)key;

/*! @name Saving an Object to Parse */

/*!
 Saves the PFObject.
 @result Returns whether the save succeeded.
 */
- (BOOL)save;

/*!
 Saves the PFObject and sets an error if it occurs.
 @param error Pointer to an NSError that will be set if necessary.
 @result Returns whether the save succeeded.
 */
- (BOOL)save:(NSError **)error;

/*!
 Saves the PFObject asynchronously.
 */
- (void)saveInBackground;
//- (void)saveInbackgroundWithBlock:(ABResultBlock)block;

/**
 *  不带token 不带hud
 */
- (void)saveInbackgroundOnSuccess:(ABSaveSuccessBlock)successBlock onFailureBlock:(ABFailureBlock)failureBlock;

/**
 *  带token 不带hud
 */
- (void)saveInbackgroundWithHasHeader:(BOOL)hasToken OnSuccess:(ABSaveSuccessBlock)successBlock onFailureBlock:(ABFailureBlock)failureBlock;

/**
 *  返回数据是数组
 */
- (void)saveInBackgroundArrayOnSuccess:(ABResultsArraySuccessBlock)successBlock onFailureBlock:(ABFailureBlock)failureBlock;

/**
 *  带token 带hud
 */
-(void)saveInbackgroundWithHasHeader:(BOOL)hasToken withNoHud:(BOOL)noHud OnSuccess:(ABSaveSuccessBlock)successBlock onFailureBlock:(ABFailureBlock)failureBlock;

/**
 *  get 请求
 */
- (void)saveGetInbackgroundOnSuccess:(ABSaveSuccessBlock)successBlock onFailureBlock:(ABFailureBlock)failureBlock;

/**
 *  AFMultipartFormData
 */
-(void)saveInbackgroundFormDataWithHasHeader:(BOOL)hasToken withNoHud:(BOOL)noHud OnSuccess:(ABSaveSuccessBlock)successBlock onFailureBlock:(ABFailureBlock)failureBlock;
/**
 *  AFMultipartFormData 上传头像
 */
-(void)saveInbackgroundUpdataUserHeaderWithHasHeader:(BOOL)hasToken withFile:(NSData *)file OnSuccess:(ABSaveSuccessBlock)successBlock onFailureBlock:(ABFailureBlock)failureBlock;


@end
